Get the number of following on twitterΒΆ
Get the number of following on twitter.
from bs4 import BeautifulSoup
import requests
handle = input('Input your account name on Twitter: ')
temp = requests.get('https://twitter.com/'+handle)
bs = BeautifulSoup(temp.text,'lxml')
try:
following_box = bs.find('li',{'class':'ProfileNav-item ProfileNav-item--following'})
following = following_box.find('a').find('span',{'class':'ProfileNav-value'})
print("{} is following {} people.".format(handle,following.get('data-count')))
except:
print('Account name not found...')
Output:
Input your account name on Twitter: XXXXXXXXXXX
XXXXXXXXXX is following 110 people.